<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <script src="../vue.js"></script>
    <style>
      .red {
        width: 100px;
        height: 100px;
        background: red;
      }
    </style>
  </head>
  <body>
    <div id="app1">
      <h1>实例1</h1>
      <p>爸爸的钱包余额: {{money}}</p>
      <son @hehe="pay"></son>
    </div>

    <!-- fa -->
    <template id="son">
      <div>
        <h1>这里是son组件</h1>
        <button @click="buy">buybuybuy</button>
      </div>
    </template>

    <script>
      Vue.component("son", {
        template: "#son",
        methods: {
          buy() {
            console.log(111)
            this.$emit('hehe',5)
          }
        },
      });

      new Vue({
        el: "#app1",
        data: {
          money: 20,
        },
        methods: {
          pay(num) {
            this.money -= num
          }
        }
      });
    </script>
  </body>
</html>
